package com.manager.user.module.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class FolderInfo implements Serializable {
    private String id;
    private String name;
    private String parentId;
    private boolean expanded = false;//是否展开
    private boolean loaded = true;
    private boolean selected;//是否选中
    private boolean last = false;//是否还有下一级
    private String levelCode;
    private int level;
    private List<FolderInfo> children;
    private String createTime;
    private String modifyTime;
    private int childrenCount;

    public FolderInfo() {
    }

    public FolderInfo(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public void addChild(FolderInfo child) {
        if (this.children == null) {
            this.children = new ArrayList<>();
        }
        this.children.add(child);
    }

    public boolean getLast() {
        if (children != null && !children.isEmpty()) {
            return true;
        }
        return childrenCount > 0;
    }

    public int getChildrenCount() {
        return childrenCount;
    }

    public void setChildrenCount(int childrenCount) {
        this.childrenCount = childrenCount;
    }

    public void setLast(boolean last) {
        this.last = last;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public boolean isExpanded() {
        return expanded;
    }

    public void setExpanded(boolean expanded) {
        this.expanded = expanded;
    }

    public boolean getLoaded() {
        if (!expanded && getLast() && childrenCount > 0) {
            return false;
        }
        return loaded;
    }

    public void setLoaded(boolean loaded) {
        this.loaded = loaded;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public List<FolderInfo> getChildren() {
        if (children == null) {
            children = new ArrayList<>();
        }
        return children;
    }

    public void setChildren(List<FolderInfo> children) {
        this.children = children;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLevelCode() {
        return levelCode;
    }

    public void setLevelCode(String levelCode) {
        this.levelCode = levelCode;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(String modifyTime) {
        this.modifyTime = modifyTime;
    }
}
